// 这里只封装组织架构相关的接口

import request from '@/utils/request'

/**
 * 获取部门列表
 */
export const reqGetDepartments = () => {
  return request({
    method: 'get',
    url: '/company/department'
  })
}

/**
 * 根据id删除部门
 * @param {*} id 部门id
 */
export const reqDelDepartment = (id) => {
  return request({
    method: 'delete',
    url: `/company/department/${id}`
  })
}

/**
 * 获取部门负责人简单列表
 */
export const reqGetSimpleUserList = () => {
  return request({
    method: 'get',
    url: '/sys/user/simple'
  })
}

/**
 * 添加子部门
 * @param {*} form
 */
export const reqAddDepartment = (form) => {
  return request({
    method: 'post',
    url: '/company/department',
    data: form
  })
}

/**
 * 根据id查询部门详情
 * @param {*} id 部门id
 */
export const reqGetDepartDetailById = (id) => {
  return request({
    method: 'get',
    url: `/company/department/${id}`
  })
}

/**
 * 更新部门详情
 * @param {*} form
 */
export const reqUpdateDepartment = (form) => {
  return request({
    method: 'put',
    url: `/company/department/${form.id}`,
    data: form
  })
}
